package com.vipshop.compass.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil extends org.apache.commons.lang.StringUtils {

	public static boolean isEmptyOrNull(Object val) {
		if (val == null) {
			return true;
		} else if ("".equals((val.toString().trim()))) {
			return true;
		} else {
			return false;
		}
	}

	public static void main(String args[]) {
		System.out.print(validateEmail("levinslevin.cam"));
	}

	public static boolean validateEmail(final String mail) {
		Matcher matcher;
		String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
		Pattern pattern = Pattern.compile(EMAIL_PATTERN);
		matcher = pattern.matcher(mail);
		return matcher.matches();

	}

}
